import requests
from bs4 import BeautifulSoup as bs
url='https://www.imooc.com'
header={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Edg/97.0.1072.55'}
response=requests.get(url=url,headers=header)
soup=bs(response.text,'lxml')
classes=soup.find_all('p',class_='title ellipsis2')
f=iter(open('classes.txt','w'))
for tag in classes:
    title=tag.text.strip().replace('\xa0','')
    f.write(title+'\n')
f.close()
